package com.tanfuqi.sicent.server.controller

import com.tanfuqi.sicent.protocol.message.Message
import com.tanfuqi.sicent.server.filter.sent
import io.swagger.annotations.ApiOperation
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Flux

@RestController
class ShiftController : BaseController() {
    @ApiOperation("交班记录")
    @GetMapping("/shop/{shopId}/shift/from/{from}/to/{to}")
    fun shift(@PathVariable shopId: String, @PathVariable from: Long, @PathVariable to: Long): Flux<Any> =
            session(shopId).sent(Message(0x9002, body = mapOf("from" to from, "to" to to))).flatMapMany { Flux.fromIterable(it.body as List<*>) }
}